home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-07-14 | 101.0 KB | 2,129 lines |
- /***********************************************************/
- /* XC.C */
- /* */
- /* Last modified: 11:00 14 July 86 L.P. */
- /* Version 1.16 */
- /* */
- /* Abstract: */
- /* */
- /* 'XC' is a cross-reference utility for 'C' programs. */
- /* Its has the ability to handle nested include files */
- /* to a depth of 8 levels and properly processes nested */
- /* comments as supported by BDS C. Option flags support */
- /* the following features: */
- /* */
- /* - Routing of list output to disk */
- /* - Cross-referencing of reserved words */
- /* - Processing of nested include files */
- /* - Generation of listing only */
- /* */
- /* Usage: xc <filename> <flag(s)> */
- /* */
- /* Flags: -i = Enable file inclusion */
- /* -l = Generate listing only */
- /* -c = Compressed print listing */
- /* -r = Cross-ref reserved words */
- /* -o <filename> = Write output to named file */
- /* */
- /*************************************************************************/
- /* 7-2-86 Changes L. Paper */
- /* - WARNING. LINK TO THE _MAIN WHICH WAS NOT COMPILED WITH TINY */
- /* DEFINED UNDER LATTICE C, VER. 3.0. Lattice shipped my copy */
- /* with _MAIN compiled with TINY. */
- /* - Changed -c from always setting the output file to PRN to only */
- /* setting it to PRN if -o has not been read. */
- /* - Changed -o option to accept either a space after the option or */
- /* the output file name immediately after the "c". */
- /* - Changed the usage display in use_err() to show the default */
- /* output for the -c option. */
- /* - Allow the input file name anywhere on the command line. */
- /* - Changed header string for Epson FX to DOUBLE STRIKE */
- /* COMPRESSED. */
- /* - Removed final trailing '.' when printing cross-references to a */
- /* file. */
- /* - Changed display output when listing to a file from a period to */
- /* a digit. Added text to separate display output '.'s when */
- /* cross-referencing from these numbers. */
- /* - Added -t option to reset tab default from command line. */
- /* - Added compile time switch for Lattice C Ver. 3. */
- /* - Included dos.h, correctec reg and changed int86(0x21, to */
- /* intdos(... for Lattice C. */
- /* - Simplified the original and corrected date and time section for */
- /* both the Computer Innovations compiler and Lattice C */
- /* Version 2 by the proprocessor variables REG and INT21. */
- /* - Eliminated all DOS calls for Lattice C, Ver. 3 with the new */
- /* functions getft and getclk. */
- /* - Added the pointer variable next_ref to the struct rf_blk to */
- /* allow for different sizes of pointers. */
- /* - Changed program to reflect new data structure. */
- /* - Removed spurious cross-reference line when the last line had */
- /* exactly eight references and added a blank line between */
- /* variables. */
- /* - Added \ to include file names for Lattice C, Ver. 3, which */
- /* accepts path names */
- /* - Added code to free dynamic storage after its contents are */
- /* printed. */
- /* - For LATTICE C VERSION 3 compilation only, changed -i option */
- /* so it searches for #include files in subdirectories which */
- /* are named in the environment variable with the same name as the */
- /* extension of the include file's name, then in subdirectories */
- /* which are named in the environment variable INCLUDE. Added a */
- /* -in option which searches only for the file name as specified. */
- /*************************************************************************/
- /* 5-20-86 Changes L. Paper */
- /* - WARNING. COMPILE WITH THE -w SWITCH SET UNDER LATTICE C VER. */
- /* 3.0, at least for the small model. */
- /* - Made several small changes to compile under Lattice C ver 3.0. */
- /* - Replaced PRN: with PRN for the -c option. */
- /* - Increased length of file names for maximum path. */
- /* - Added default .c extension for input file. */
- /* - Changed trailer string for Epson FX to EMPHASIZED PICA. */
- /* - Modified printing of trailer string so it is only with -c */
- /* option, and then before EOF, not after it. */
- /*************************************************************************/
- /* 5-20-84 Changes R.S. White */
- /* - made compilation for Lattice C ver 2.0 or Computer Innovations */
- /* CI-C86 optional by setting #define labels accordingly. */
- /* - made printer selection for compressed print selectable by */
- /* setting #define labels accordingly. Added Epson FX and */
- /* Gemini-10X printer control strings. */
- /*************************************************************************/
- /* 1-01-84 Enhancements S.R. Jacobson */
- /* - changed -e option to -c option and added two strings: */
- /* cprint_hdr sets the printer to compressed print mode */
- /* cprint_trlr resets the printer to "normal" mode */
- /* This makes it easier for non-epson printer users */
- /* - removed all the BDS C comments (this makes it easier to modify */
- /* in the future. */
- /* - changed name of the utility to the "print" utility */
- /* - if the -i flag is not used, the second line number will not */
- /* appear. */
- /* - if a form feed is detected in the source file, a new page is */
- /* started. This is useful for structuring the source */
- /* code by placing each major section on a separate page. */
- /* You do this by embedding a form feed (control L) in a */
- /* comment. The text following the form feed will be placed */
- /* on the top of the new page. */
- /* - tab characters in the file are expanded to every 8 positions. */
- /* This may be changed by changing the TABCNT define. */
- /* - added the date and time to the printed output. (C-86 only) */
- /* - fixed error in hashing algorithm. */
- /* - control characters (other than \n, \f, or \t) are stripped */
- /* from the input stream (converted to blanks). This */
- /* prevents extraneous control chars from interfering with */
- /* operation of xc. */
- /* - cleaned up the structuring of a number of routines. */
- /* - added the file latest update date and time to the printed */
- /* output. ***DOS 2.0 ONLY *** */
- /*************************************************************************/
- /* 9-26-83 Microsoft C 1.04 Conversion WHR */
- /* - \t between line numbers and text to fix indenting problem. */
- /* - added option -e for output to Epson in condensed print. */
- /* - toupper() and isupper() are macros, not functions. */
- /* - eliminate side effect in toupper(*++arg) in main(). */
- /* - change alloc() to malloc(). */
- /* - add #define NAMES that are not in stdio.h */
- /* - MS-C requires () in statement A?(c=B):(c=C) error or not?? */
- /* */
- /* 4-30-83 Computer Innovations C-86 1.31 Conversion WHR */
- /* - #include filename changed to allow a disk drive prefix, D: */
- /* - convert if(fprintf(...) == ERROR) lst_err(); to fprintf(..); */
- /* - convert if(fopen(...) == ERROR) statements to == NUL0. */
- /* - C86 requires () in statement A?(c=B):(c=C) error or not?? */
- /* - remove getc() == ERROR check in fil_chr(). */
- /* - convert file conventions from BDS C to C-86. */
- /* - comment out BDS unique statements, mark revised statements. */
- /* keep all BDS statements to document conversion effort. */
- /* */
- /** 4-19-83 BDS C Version file XC.CQ copied from Laurel RCPM WHR */
- /*************************************************************************/
- /* ** Original Version: ** */
- /* */
- /* Version 1.0 January, 1982 */
- /* */
- /* Copyright (c) 1982 by Philip N. Hisley */
- /* */
- /* Released for non-commercial distribution only */
- /* */
- /* Please report bugs/fixes/enhancements to: */
- /* */
- /* Philip N. Hisley */
- /* 548H Jamestown Court */
- /* Edgewood, Maryland 21040 */
- /* (301) 679-4606 */
- /* Net Addr: PNH@MIT-AI */
- /* */
- /* */
- /***********************************************************/
-
- /* DEFINITIONS AND VARIABLES */ /*SRJ*/
-
- #define LATTICE2 0 /* Set to use Lattice C Ver. 2.x compiler. LP */
- #define LATTICE3 1 /* Set to use Lattice C Ver. 3.0 compiler. LP */
- #define CIC86 0 /* disable Computer Innovations compiler */ /*RSW*/
-
- #define GEMIN10X 0 /* enable Gemini-10X printer codes */ /*RSW*/
- #define EPSONMX 0 /*RSW*/
- #define EPSONFX 1 /*RSW*/
- #define IDSPRISM 0 /*RSW*/
-
- #define TAB_DFLT 3 /* Default value for tab_cnt. XC expands */
- /* tabs to every tab_cnt characters. LP */
-
- /*************************************************************************/
- /* */
- /* This section and the functions at the end of the program are */
- /* compiler-sensitive. Since I do not now have access to Lattice C, */
- /* Version 2 or to Computer Innovations C-86, I may have unwittingly */
- /* introduced some bugs by adding switches and moving code. */
- /* */
- /* The last #else represents my best guess as to what other compilers */
- /* might do. I have not tried to guess in all cases, so other */
- /* compilers will have some undefined symbols which the programmer */
- /* must adapt. */
- /* */
-
- /* --------------- Include files */ /*LP*/
-
- #if CIC86 /*LP*/
- #include <stdio.h> /*WHR*/
- #else /*LP*/
-
- #if LATTICE2 /*LP*/
- #include <stdio.h> /*WHR*/
- #include <ctype.h> /* Lattice C ver 2.0 and 3.0 - macros */ /*RSW*/
- #else /*LP*/
-
- #if LATTICE3 /*LP*/
- #include <stdio.h> /*WHR*/
- #include <stdlib.h> /*LP*/
- #include <dos.h> /* Also defines LATTICE as 1 */ /*LP*/
- #include <string.h> /*LP*/
- #include <ctype.h> /* Lattice C ver 2.0 and 3.0 - macros */ /*RSW*/
-
- #else /* Other */ /*LP*/
- #include <stdio.h> /*WHR*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- LATTICE preprocessor variable */ /*LP*/
-
- #if CIC86 /*LP*/
- #define LATTICE 0 /*LP*/
- #else /*LP*/
- #if LATTICE2 /*LP*/
- #define LATTICE 1 /* set to use Lattice C ver 2.0 compiler */ /*RSW*/
- #else /*LP*/
- #if LATTICE3 /*LP*/
- /* Defined as 1 in dos.h */ /*LP*/
- #else /* Other */ /*LP*/
- #define LATTICE 0 /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- void type */ /*LP*/
-
- #if CIC86 /*LP*/
- #define void int /*LP*/
- #else /*LP*/
- #if LATTICE2 /*LP*/
- #define void int /*LP*/
- #else /*LP*/
- #if LATTICE3 /*LP*/
- /* void is defined in Lattice, Version 3 */
- #else /* Other */ /*LP*/
- #define void int /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Function prototyping control */ /*LP*/
- /* Lattice C, Version 3 enables function prototyping unless NARGS is */ /*LP*/
- /* is defined. If your compiler uses a different method, adjust */ /*LP*/
- /* this subsection. */ /*LP*/
-
- #if CIC86 /*LP*/
- #define NARGS /*LP*/
- #else /*LP*/
- #if LATTICE2 /*LP*/
- #define NARGS /*LP*/
- #else /*LP*/
- #if LATTICE3 /*LP*/
- /* Leave NARGS undefined to enable function prototyping */ /*LP*/
- #else /* Other */ /*LP*/
- /* Assume the other compiler does not implement function prototyping */ /*LP*/
- #define NARGS /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Library function declarations */ /*LP*/
-
- #if CIC86 /*LP*/
- void segread(); /*LP*/
- void sysint(); /*LP*/
- char *strcpy();
- char *strchr(), *strcat(); /*LP*/
- int toupper(); /* toupper in Lattice C is a macro with side effects */
- /*LP*/
- #else /*LP*/
-
- #if LATTICE2 /*LP*/
- int dosint(); /*LP*/
- char *strcpy();
- char *strchr(), *strcat(); /*LP*/
- int fileno(); /*LP*/
- #else /*LP*/
-
- #if LATTICE3 /*LP*/
- /* Declared by included files */ /*LP*/
-
- #else /* Other */ /*LP*/
- char *strcpy();
- char *strchr(), *strcat(); /*LP*/
- int toupper(); /* toupper in Lattice C is a macro with side effects */
- /*LP*/
- int fileno(); /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
-
- /* --------------- struct rf_blk */ /*LP*/
-
- #define MAX_REF 5 /* maximum refs per ref-block */
-
- #if CIC86 /*LP*/
- struct rf_blk
- {
- int ref_item[MAX_REF];
- int ref_cnt;
- } onerf;
- #define NEXT_REF ref_cnt /*LP*/
- #define IS_PTR(rf_ptr) rf_ptr > (struct rf_blk *) MAX_REF /*LP*/
- #else /*LP*/
-
- #if LATTICE /*LP*/
- struct rf_blk
- {
- int ref_item[MAX_REF];
- int ref_cnt;
- struct rf_blk *next_ref; /*LP*/
- } onerf;
- #define NEXT_REF next_ref /*LP*/
- #define IS_PTR(rf_ptr) rf_ptr /* TRUE if rf_ptr is not NULL */ /*LP*/
- #else /* Other */ /*LP*/
-
- struct rf_blk
- {
- int ref_item[MAX_REF];
- int ref_cnt;
- struct rf_blk *next_ref; /*LP*/
- } onerf;
- #define NEXT_REF next_ref /*LP*/
- #define IS_PTR(rf_ptr) rf_ptr /* TRUE if rf_ptr is not NULL */ /*LP*/
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- DOS interrupt pre-processor definitions */ /*LP*/
-
- #if CIC86 /*LP*/
- #define INT21 sysint(0x21,&creg,&creg) /* DOS interrupt. LP */
- struct regval
- {
- unsigned int ax,bx,cx,dx,si,di,ds,es;
- }
- creg; /*structure for sysint*/ /*SRJ*/
- #define REG creg /*LP*/
-
- struct regv
- {
- unsigned int csx,ssx,dsx,esx;
- } regx; /* structure for segread*/ /*SRJ*/
-
- unsigned int handle; /* dos file handle */ /*SRJ*/
- #else /*LP*/
-
- #if LATTICE2 /*LP*/
- #define INT21 (void) intdos(&lreg, &lreg) /* DOS interrupt. LP */
- union REGS lreg; /*LP*/
- #define REG lreg.x /*LP*/
-
- unsigned int handle; /* dos file handle */ /*SRJ*/
- #else /*LP*/
-
- #if LATTICE3 /*LP*/
- /* No DOS interrupts for Lattice, Ver. 3 */
- #else /* Other */ /*LP*/
-
- /* No standard for DOS interrupts for other compilers */
-
- unsigned int handle; /* dos file handle */ /*SRJ*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Control side effect of toupper() as a macro */ /*LP*/
-
- #if CIC86 /*LP*/
- #define SIDE_1 0 /*LP*/
- #else /*LP*/
- #if LATTICE /*LP*/
- #define SIDE_1 1 /*LP*/
- #else /* Other */ /*LP*/
- #define SIDE_1 1 /* Conservative assumption */ /*LP*/
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Get the system date and time */ /*LP*/
-
- #if CIC86 /*LP*/
- #define GETCLOK getclk_1 /*LP*/
- #else /*LP*/
- #if LATTICE2 /*LP*/
- #define GETCLOK getclk_2 /*LP*/
- #else /*LP*/
- #if LATTICE3 /*LP*/
- #define GETCLOK getclk_3 /*LP*/
- #else /* Other */ /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Get file gbl_fil's date and time */ /*LP*/
-
- #if CIC86 /*LP*/
- #define GETFTM getft_1 /*LP*/
- #else /*LP*/
- #if LATTICE2 /*LP*/
- #define GETFTM getft_2 /*LP*/
- #else /*LP*/
- #if LATTICE3 /*LP*/
- #define GETFTM getft_3 /*LP*/
- #else /* Other */ /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Test whether l_buffer is a file */ /*LP*/
-
- #if CIC86 /*LP*/
- /* The code in get_ft1 implies that there is no way for Computer */ /*LP*/
- /* Innovations C-86 to find the handle of a file which it opens */ /*LP*/
- /* with an fopen function. In addition, it implies that the flags */ /*LP*/
- /* are not available from sysint. If this is true, there is no way */ /*LP*/
- /* to test whether l_buffer is a file without closing it. Since */ /*LP*/
- /* the purpose of the test is to avoid closing a device, use a */ /*LP*/
- /* dummy test. */ /*LP*/
- #define L_IS_FIL l_isf0 /*LP*/
- #else /*LP*/
- #if LATTICE2 /*LP*/
- #define L_IS_FIL l_isf2 /*LP*/
- #else /*LP*/
- #if LATTICE3 /*LP*/
- #define L_IS_FIL l_isf3 /*LP*/
- #else /*LP*/
- /* Assumes the other compiler can not check whether l_buffer is a */ /*LP*/
- /* file */ /*LP*/
- #define L_IS_FIL l_isf0 /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Flush l_buffer if necessary */ /*LP*/
-
- #if CIC86 /*LP*/
- #define L_FLUSH l_fl1 /*LP*/
- #else /*LP*/
- #if LATTICE /*LP*/
- #define L_FLUSH l_fl0 /*LP*/
- #else /*LP*/
- /* Assumes that other compiler does not need to flush l_buffer */ /*LP*/
- #define L_FLUSH l_fl0 /*LP*/
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Expression which is true for valid file name */ /*LP*/
- /* --------------- character which is not alphanumeric of an */ /*LP*/
- /* --------------- underscore. */ /*LP*/
-
- #if CIC86 /*LP*/
- #define IS_PATH FALSE /*LP*/
- #define IS_FCHAR (c == '.' || c == ':') /* No path */ /*LP*/
- #else /*LP*/
- #if LATTICE /*LP*/
- #define IS_PATH *g_token != '\\' /*LP*/
- #define IS_FCHAR (c == '\\' || c == '.' || c == ':') /* Path */ /*LP*/
- #else /* Other */ /*LP*/
- #define IS_PATH FALSE /*LP*/
- #define IS_FCHAR (c == '.' || c == ':') /* Assume no path */ /*LP*/
-
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Declare memory allocation functions */ /*LP*/
-
- #if CIC86 /*LP*/
- char *alloc(); /*LP*/
- #define NULL_PTR 0 /*LP*/
- #else /*LP*/
-
- #if LATTICE2 /*LP*/
- char *getmem(); /*LP*/
- int allmem(); /*LP*/
- void rstmem(); /*LP*/
- #define NULL_PTR NULL /*LP*/
- #else /*LP*/
-
- #if LATTICE3 /*LP*/
- /* Declared in header file STDLIB.H */ /*LP*/
- #define NULL_PTR NULL /*LP*/
- #else /* Other */ /*LP*/
-
- /* Assume the other compiler follows the UNIX standard */ /*LP*/
- char *malloc(); /*LP*/
- #define NULL_PTR NULL /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Functions to allocate an id_blk */ /*LP*/
-
- #if CIC86 /*LP*/
- #define ID_ALLOC alloc(sizeof(oneid)) /*LP*/
- #else /*LP*/
-
- #if LATTICE /*LP*/
- #define ID_ALLOC (struct id_blk *) getmem((unsigned) sizeof(oneid)) /*LP*/
-
- #else /* Other */ /*LP*/
- /* Assume the other compiler follows the UNIX standard */ /*LP*/
- #define ID_ALLOC (struct id_blk *) malloc((unsigned) sizeof(oneid)) /*LP*/
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Functions to allocate and free a rf_blk */ /*LP*/
-
- #if CIC86 /*LP*/
- #define RF_ALLOC alloc(sizeof(onerf)) /*LP*/
- #else /*LP*/
-
- #if LATTICE /*LP*/
- #define RF_ALLOC (struct rf_blk *) getmem((unsigned) sizeof(onerf)) /*LP*/
-
- #else /* Other */ /*LP*/
- /* Assume the other compiler follows the UNIX standard */ /*LP*/
- #define RF_ALLOC (struct rf_blk *) malloc((unsigned) sizeof(onerf)) /*LP*/
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Lattice get and release dynamic memory */ /*LP*/
- /* --------------- With luck, may prevent termination problems */ /*LP*/
-
- #if CIC86 /*LP*/
- /* Dummy function for non-Lattice compilers */ /*LP*/
- int d_dyn() /*LP*/
-
- { /*LP*/
- return(0); /*LP*/
- } /*LP*/
- #define GETDYN d_dyn; /*LP*/
- #define RELDYN (void) d_dyn; /*LP*/
- #else /*LP*/
-
- #if LATTICE /*LP*/
- #define GETDYN allmem /*LP*/
- #define RELDYN rstmem /*LP*/
-
- #else /* Other */ /*LP*/
- /* Dummy function for non-Lattice compilers */ /*LP*/
- int d_dyn() /*LP*/
-
- { /*LP*/
- return(0); /*LP*/
- } /*LP*/
- #define GETDYN d_dyn; /*LP*/
- #define RELDYN (void) d_dyn; /*LP*/
- #endif /* LATTICE */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* --------------- Lattice Version 3 for include path */ /*LP*/
-
- #if CIC86 /*LP*/
- #define IN_FALSE /* Dummy */ /*LP*/
- #define CHK_IN /* Dummy */ /*LP*/
- #define I_MESS i_mes1 /*LP*/
- #define OPEN_IN opn_i1 /*LP*/
- #else /*LP*/
-
- #if LATTICE2 /*LP*/
- #define IN_FALSE /* Dummy */ /*LP*/
- #define CHK_IN /* Dummy */ /*LP*/
- #define I_MESS i_mes1 /*LP*/
- #define OPEN_IN opn_i1 /*LP*/
- #else /*LP*/
-
- #if LATTICE3 /*LP*/
- int in_flg; /* -in on command line */ /*LP*/
- #define IN_FALSE in_flg = FALSE; /*LP*/
- /* Lattice probably does not support multiple line macros */ /*LP*/
- #define CHK_IN ++arg; if (toupper(*arg) == 'N') in_flg++; /*LP*/
- #define I_MESS i_mes2 /*LP*/
- #define OPEN_IN opn_i2 /*LP*/
-
- #else /* Other */ /*LP*/
- /* Assume other compiler does not support paths for includes */ /*LP*/
- #define IN_FALSE /* Dummy */ /*LP*/
- #define CHK_IN /* Dummy */ /*LP*/
- #define I_MESS i_mes1 /*LP*/
- #define OPEN_IN opn_i1 /*LP*/
- #endif /* LATTICE3 */ /*LP*/
- #endif /* LATTICE2 */ /*LP*/
- #endif /* CIC86 */ /*LP*/
-
- /* End of compiler-dependent section */
- /* */
- /*************************************************************************/
- /* Preprocessor variables which control changes by L.P. */
- /* Note that this is the technique for "commenting out" which PC-Lint */
- /* recommends. */
- /* */
- /* Send the compressed print trailer string to the output file before */
- /* the CPMEOF rather than after it. */
- #define LP_EOF 1
- /* */
- /* Remove variable rfptr, declared but not used in function put_token. */
- #define RFPTR_1 0
- /* */
- /* Remove variable f, declared but not used in function chain_alpha */
- #define F_1 0
- /* */
- /* Remove function lst_err, never referenced */
- #define LST_ERR1 0
- /* */
- /* Remove variable rhsh_cnt, never referenced */
- #define RHSH_CN1 0
- /* */
- /* Remove variable fil_cnt, never referenced */
- #define FIL_CNT1 0
- /* */
- /* Remove variable wrd_cnt, never referenced */
- #define WRD_CNT1 0
- /* */
- /*************************************************************************/
-
- #define NUL0 0
- #define FALSE 0 /*WHR*/
- #define TRUE 1 /*WHR*/
- #define CPMEOF 0x1A /* end of file */ /*WHR*/
- #define ERROR (-1) /*WHR*/
-
- #define MAX_FILE 65 /* maximum drive:path\file name + */ /*LP*/
- #define MAX_LEN 39 /* maximum identifier length -n opt Lattice C */ /*RSW*/
- #define MAX_WRD 749 /* maximum number of identifiers */
- #define MX_ALPHA 53 /* maximum alpha chain heads */ /*RSW*/
- #define REFS_LIN 8 /* maximum refs per line */ /*RSW*/
- #define LINE_PAG 60 /* note Lattice C gets confused if -n */ /*RSW*/
- /* option is used and #define labels */
- /* are longer than 8 characters */
-
- struct id_blk
- {
- char id_name[MAX_LEN];
- struct id_blk *alpha_lnk;
- struct rf_blk *top_lnk;
- struct rf_blk *lst_lnk;
- } oneid;
-
- struct id_blk *id_vector[MAX_WRD];
-
- struct alpha_hdr
- {
- struct id_blk *alpha_top;
- struct id_blk *alpha_lst;
- };
-
- struct alpha_hdr alpha_vector[MX_ALPHA];
-
- int y,mo,d; /* year,month and day for date */ /*SRJ*/
- int h,mi,s; /* hours, minutes, seconds for time */ /*SRJ*/
-
- char *months[]= /* month names for date */ /*SRJ*/
- {
- "bad month", "January", "February", "March",
- "April", "May", "June", "July", "August",
- "September", "October", "November", "December"
- }
- ;
-
- int ln_chr=0; /* # of characters in the line (for tab) SRJ */
-
- unsigned int file_d,file_mo,file_y,file_h,file_mi; /* file m/d/y and h:m SRJ */
-
- FILE *tb; /* temp fd */ /*SRJ*/
-
-
- int linum; /* line number */
- int edtnum; /* edit line number */
- #if FIL_CNT1 /*LP*/
- int fil_cnt; /* active file index */
- #endif /*LP*/
- #if WRD_CNT1 /*LP*/
- int wrd_cnt; /* token count */
- #endif /*LP*/
- int pagno; /* page number */
- int id_cnt; /* number of unique identifiers */
- #if RHSH_CN1 /*LP*/
- int rhsh_cnt; /* number of conflict hits */
- #endif /*LP*/
- int filevl; /* file level */
- int paglin; /* page line counter */
- int prt_ref;
- char act_fil[MAX_FILE]; /*LP*/
- char lst_fil[MAX_FILE]; /*LP*/
- char gbl_fil[MAX_FILE]; /*LP*/
- FILE *l_buffer; /*WHR*/
- int i_flg,o_flg,r_flg,l_flg;
- int debug;
- int c_flg; /*WHR*/
- int inp_rd; /*LP*/
- int tab_cnt; /*LP*/
-
-
- /* The following two strings are the compressed print header and the
- trailer that returns the printer to the normal mode. These must
- be changed for each printer. They are currently set up for the */
-
- #if GEMIN10X /*RSW*/
- char cprint_hdr[]="\x1bB\3\1bQ\x84"; /* header string for Gemini-10X */
- char cprint_trlr[]="\x1bB\2"; /* ELITE mode trailer string for Gemini-10X */
- #endif
-
- #if IDSPRISM /*RSW*/
- char cprint_hdr[] = "\037"; /* header string for Prism 80 */
- char cprint_trlr[] = "\035"; /* trailer string for Prism 80 */
- #endif
-
- #if EPSONMX /*RSW*/
- char cprint_hdr[] = "\x1b\x40\x0F\x1BQ\x84"; /*WHR*/
- char cprint_trlr[] = "\x1b\x40"; /* trailer string for Epson MX */
- #endif
-
- #if EPSONFX /*RSW*/
- /* DOUBLE STRIKE COMPRESSED mode header string for Epson FX */ /*WHR*/ /*LP*/
- char cprint_hdr[]="\x1b!\x14\x1bQ\x84";
- /*EMPHASIZED PICA mode trailer string for Epson FX*/ /*LP*/
- char cprint_trlr[]="\x1b!\x8";
- #endif
-
-
- /* end of printer strings */
- /* MAIN PROGRAM */ /*SRJ*/
-
-
- void main(argc,argv)
- int argc;
- char **argv;
-
- {
- char *arg;
- char cc; /* Lattice C */
-
- #ifndef NARGS /*LP*/
- void use_err(void); /*LP*/
- void proc_file(char *); /*LP*/
- void prnt_tbl(void); /*LP*/
- void prt_hdr(void); /*LP*/
- void GETCLOK(void); /*LP*/
- void GETFTM(void); /*LP*/
- int L_IS_FIL(void); /*LP*/
- void L_FLUSH(void); /*LP*/
- #else /*LP*/
- void use_err(); /*LP*/
- void proc_file(); /*LP*/
- void prnt_tbl(); /*LP*/
- void prt_hdr(); /*LP*/
- void GETCLOK(); /*LP*/
- void GETFTM(); /*LP*/
- int L_IS_FIL(); /*LP*/
- void L_FLUSH(); /*LP*/
- #endif /*LP*/
-
- /* The parameters */
-
- if (argc < 2)
- use_err();
- i_flg = r_flg = o_flg = l_flg = inp_rd = FALSE;
- IN_FALSE; /* Initialize in_flg to FALSE - Lattice only */ /*LP*/
- tab_cnt = TAB_DFLT; /*LP*/
- debug = FALSE;
- if (gbl_fil[0] == '-')
- use_err();
- while (--argc != 0)
- {
- if (*(arg =* ++argv) == '-')
- {
- #if SIDE_1
- cc = *++arg;
- switch(toupper(cc) )
- #else /*LP*/
- switch( toupper(*++arg) ) /* Has side effect in Lattice C */
- #endif /*LP*/
- {
-
- case 'I':
- i_flg++;
- CHK_IN; /* Check for -in, set in_flg - Lattice only */ /*LP*/
- break;
-
- case 'R':
- r_flg++;
- break;
-
- case 'L':
- l_flg++;
- break;
-
- case 'O':
- {
- o_flg++;
- if (!*++arg) /*LP*/
- { /*LP*/
- if (--argc == 0) /*LP*/
- use_err(); /*LP*/
- (void) strcpy(lst_fil,*++argv); /*LP*/
- } /*LP*/
- else /*LP*/
- (void) strcpy(lst_fil,arg); /*LP*/
- if (lst_fil[0] == '-')
- use_err();
- if (debug)
- printf("lst_fil=>%s<",lst_fil);
- break;
- }
-
- case 'D':
- debug++;
- break;
-
- case 'C': /*SRJ*/ /*WHR*/
- c_flg++;
- if (!o_flg) /*LP*/
- {
- o_flg++;
- (void) strcpy(lst_fil,"PRN"); /*SRJ*/
- }
- break;
-
- case 'T': /*LP*/
- if (!*++arg) /* Space after -t. LP */
- {
- /* Point arg to next word. LP */
- if (--argc == 0) /*LP*/
- use_err(); /*LP*/
- arg = *++argv; /*LP*/
- } /*LP*/
- tab_cnt = 0; /* Get tab_cnt. LP */
- if (isdigit(*arg)) /*LP*/
- { /*LP*/
- tab_cnt = *arg++ - '0'; /*LP*/
- if (isdigit(*arg)) /*LP*/
- tab_cnt = 10 * tab_cnt + (*arg++ - '0'); /*LP*/
- } /*LP*/
- if ((!tab_cnt) || /* Empty count. LP */
- (*arg)) /* Count too big or a tramp character. LP */
- use_err(); /*LP*/
- break; /*LP*/
-
- default:
- use_err();
- }
- } /* if (*(arg =* ++argv) == '-') */
- else
- {
- if (inp_rd) /*LP*/
- use_err();
- else
- { /*LP*/
- inp_rd++; /*LP*/
- strcpy(gbl_fil,*argv);
- if (!strchr(gbl_fil, '.')) /* No file extension */ /* LP */
- strcat(gbl_fil, ".c"); /* Add default .c */ /* LP */
- }
- } /*else for if (*(arg =* ++argv) == '-') */
- } /* while (--argc != 0) */
- if (!inp_rd) /*LP*/
- use_err(); /*LP*/
- if (debug)
- printf("\ni_flg=%d, r_flg=%d, l_flg=%d", i_flg,r_flg,l_flg);
- if (debug)
- printf("\no_flg=%d, debug=%d", o_flg,debug);
- if (o_flg)
- {
- if ( (l_buffer = fopen(lst_fil,"w")) == NUL0) /*** output file ***/
- {
- printf("ERROR: Unable to create list file - %s\n",lst_fil);
- exit(0);
- }
- printf("\nXC ....... 'C' Print Utility v1.1\n"); /*RSW*/
- if (c_flg)
- fprintf(l_buffer,"%s",cprint_hdr);
- }
- else /*SRJ*/
- l_buffer=stdout; /* if no output file, use stdout */ /*SRJ*/
-
- GETCLOK(); /* Get the system date and time */ /*LP*/
-
- /* NOW WE GET THE FILE LATEST UPDATE DATE AND TIME */
-
- /* first try to open the file */
-
- if ((tb = fopen(gbl_fil,"r")) == NUL0) /*open the input file */ /*SRJ*/
- {
- printf("\nERROR: Unable to open input file: %s\n",gbl_fil); /*SRJ*/
- exit(10); /*SRJ*/
- }
- GETFTM(); /*LP*/
-
- prt_ref = FALSE;
- for (linum = 0; linum < MAX_WRD; linum++)
- id_vector[linum] = NUL0;
-
- for (linum = 0; linum < MX_ALPHA; linum++)
- alpha_vector[linum].alpha_top =
- alpha_vector[linum].alpha_lst = NUL0;
-
- #if FIL_CNT1 /*LP*/
- fil_cnt = 0; /*LP*/
- #endif /*LP*/
- #if WRD_CNT1 /*LP*/
- wrd_cnt = 0; /*LP*/
- #endif /*LP*/
- linum = 0; /*LP*/
- filevl = paglin = pagno = edtnum = 0;
- id_cnt = 0;
- #if RHSH_CN1 /*LP*/
- rhsh_cnt =0;
- #endif /*LP*/
- if (GETDYN()) /* Get dynamic memory - Lattice only */ /*LP*/
- { /*LP*/
- printf("\nUnable to get dynamic memory\n"); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
- proc_file(gbl_fil);
- if (!l_flg)
- {
- prnt_tbl();
- printf("\nAllowable Symbols: %d\n", MAX_WRD);
- printf("Unique Symbols: %d\n", id_cnt);
- }
- RELDYN(); /* Release dynamic memory - Lattice only */ /*LP*/
- if (o_flg)
- {
- fputc('\n',l_buffer); /* output cr/lf */ /*SRJ*/ /*LP*/
- if (++paglin >= LINE_PAG ) /*LP*/
- prt_hdr(); /*LP*/
- fprintf(l_buffer,"\nAllowable Symbols: %d\n", MAX_WRD); /*WHR*/
- fprintf(l_buffer,"Unique Symbols: %d\n", id_cnt); /*WHR*/
- #if LP_EOF /* Send EOF after output trailer string rather than */ /*LP*/
- /* before it */ /*LP*/
- fputc('\f', l_buffer); /*LP*/
- if (c_flg) /* Only output trailer if -c */ /*LP*/
- fprintf(l_buffer,"%s", cprint_trlr); /* output trailer */ /*SRJ*/
- fputc(CPMEOF, l_buffer); /*LP*/
- #else /*LP*/
- fprintf(l_buffer,"\f%c", CPMEOF); /*WHR*/
- if (c_flg) /* Only output trailer if -c */ /*LP*/
- fprintf(l_buffer,"%s", cprint_trlr); /* output trailer */ /*SRJ*/
- #endif /*LP*/
- if (L_IS_FIL()) /* l_buffer is a file */ /*LP*/
- {
- L_FLUSH(); /*LP*/
- if (fclose(l_buffer)) /*LP*/
- { /*LP*/
- printf
- ("\nERROR: Unable to close output file: %s\n", lst_fil); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
- }
- }
- }
- /* ERROR MESSAGE PRINT ROUTINES */ /*SRJ*/
-
- #if LST_ERR1 /* Not used */ /*LP*/
- void lst_err()
-
- {
- printf("\nERROR: Write error on list output file - %s\n", lst_fil);
- exit(0);
- }
- #endif /*LP*/
-
- void use_err()
-
- {
- #ifndef NARGS
- void I_MESS(void);
- #else
- void I_MESS();
- #endif
-
- printf("\nERROR: Invalid parameter specification\n\n");
- printf("Usage: xc <filename> <flag(s)>\n\n");
- printf("Flags: -i = "); /*LP*/
- I_MESS(); /* Print message for -i */ /*LP*/
- printf(" -l = Generate listing only\n");
- printf(" -c = Compressed print option. Change the\n");
- /*SRJ*/ /*LP*/
- printf(" default output file to the printer\n");
- /*LP*/
- printf(" -r = Cross-reference reserved words\n");
- printf(" -o <filename> = Write output to named file\n");
- printf(" -t <tab_count> = Reset tab count from default %d\n",
- TAB_DFLT); /*LP*/
- exit(0);
- }
-
- /* PROCESS THE FILE */ /*SRJ*/
-
- void proc_file(filnam)
-
- char *filnam;
-
- {
- FILE *buffer; /* allocated buffer pointer */ /*WHR*/
- char token[MAX_LEN]; /* token buffer */
- int eof_flg; /* end-of-file indicator */
- int tok_len; /* token length */
- int incnum; /* included line number */
- #ifndef NARGS /*LP*/
- FILE *OPEN_IN(char *); /*LP*/
- int get_token(FILE *, char *, int *, int *, int); /*LP*/
- int chk_token(char *); /*LP*/
- void put_token(char *, int); /*LP*/
- void prt_hdr(void); /*LP*/
- void nl(void); /*LP*/
- #else /*LP*/
- FILE *OPEN_IN();
- int get_token(); /*LP*/
- int chk_token(); /*LP*/
- void put_token(); /*LP*/
- void prt_hdr(); /*LP*/
- void nl(); /*LP*/
- #endif /*LP*/
-
- (void) strcpy(act_fil,filnam); /*LP*/
- if ((buffer = OPEN_IN(filnam)) == NUL0) /*** input file ***/ /*WHR*/ /*LP*/
- {
- printf("\nERROR: Unable to open input file: %s\n", filnam);
- exit(0);
- }
- if (filevl++ == 0)
- {
- prt_hdr();
- nl();
- }
- eof_flg = FALSE;
- do /* while (!eof_flg) */
- {
- if (get_token(buffer, token, &tok_len, &eof_flg, 0))
- {
- if (debug)
- printf("token: %s length: %d\n", token, tok_len);
- if (chk_token(token))
-
- /* #include processing changed to accept drive: WHR */
- {
- if (strcmp(token, "#include") == 0)
- {
- if (get_token(buffer, token, &tok_len, &eof_flg,1))
- {
- if (debug)
- printf("**token: %s length: %d\n",
- token, tok_len);
- if (!i_flg)
- continue;
- else
- {
- incnum = edtnum;
- edtnum = 0;
- nl();
- proc_file(token);
- edtnum = incnum;
- (void) strcpy(act_fil, filnam);
- continue;
- } /* else for if (!i_flg) */
- } /* if (get_token(buffer, token, &tok_len, &eof_flg,1)) */
- } /* if (strcmp(token, "#include") == 0) */
- put_token(token, linum);
- } /* if (chk_token(token)) */
- } /* if (get_token(buffer, token, &tok_len, &eof_flg, 0)) */
- }
- while (!eof_flg);
-
- filevl -= 1;
- if (fclose(buffer)) /*LP*/
- { /*LP*/
- printf("\nERROR: Unable to close input file: %s\n", filnam); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
- return;
- }
- /* GET A TOKEN */ /*SRJ*/
-
- int get_token(g_buffer, g_token, g_toklen, g_eoflg, g_flg)
-
- FILE *g_buffer;
- char *g_token;
- int *g_toklen;
- int *g_eoflg;
- int g_flg;
-
- /*
- * 'getoken' returns the next valid identifier or
- * reserved word from a given file along with the
- * character length of the token and an end-of-file
- * indicator
- *
- */
-
- {
- int c;
- char *h_token;
- #ifndef NARGS
- char rdchr(FILE *, int *, int);
- #else
- char rdchr();
- #endif
-
- h_token = g_token;
-
- gtk: /* top of loop, get new token */
- *g_toklen = 0;
- g_token = h_token;
-
- /*
- * Scan and discard any characters until an alphabetic or
- * '_' (underscore) character is encountered or an end-of-file
- * condition occurs
- */
-
- while ( (!isalpha(*g_token = rdchr(g_buffer, g_eoflg, g_flg)))
- && !*g_eoflg && *g_token != '_'
- && *g_token != '0' && *g_token != '#'
- && IS_PATH) /*LP*/
- ;
- if (*g_eoflg)
- return(FALSE);
-
- *g_toklen += 1;
-
- /*
- * Scan and collect identified alpanumeric token until
- * a non-alphanumeric character is encountered or and
- * end-of-file condition occurs
- */
-
- while ( (isalpha(c=rdchr(g_buffer, g_eoflg, g_flg)) ||
- isdigit(c) || c == '_' || /*LP*/
- /* Check for extra characters in #include file name */ /*LP*/
- (g_flg && IS_FCHAR)) /*LP*/
- && !*g_eoflg) /* WHR fix for B:filename.ext */
- {
- if (*g_toklen < MAX_LEN)
- {
- *++g_token = c;
- *g_toklen += 1;
- }
- }
-
-
- /*
- * Check to see if a numeric hex or octal constant has
- * been encountered ... if so dump it and try again
- */
-
-
- if (*h_token == '0')
- goto gtk;
-
-
- /*
- * Tack a NUL0 character onto the end of the token
- */
-
- *++g_token = NUL0;
-
- /*
- * Screen out all #token strings except #include
- */
-
- if (*h_token == '#' && strcmp(h_token, "#include"))
- goto gtk;
-
- return (TRUE);
- }
- /* READ A CHARACTER FROM THE FILE AND PROCESS IT */ /*SRJ*/
-
-
- char rdchr(r_buffer, r_eoflg, rd_flg) /*LP*/
- FILE *r_buffer;
- int *r_eoflg;
- int rd_flg;
-
- /*
- 'rdchr' returns the next valid character in a file
- and an end-of-file indicator. A valid character is
- defined as any which does not appear in either a
- commented or a quoted string ... 'rdchr' will correctly
- handle comment tokens which appear within a quoted
- string
- */
-
- {
- int c;
- int q_flg; /* double quoted string flag */
- int q1_flg; /* single quoted string flag */
- int cs_flg; /* comment start flag */
- int ce_flg; /* comment end flag */
- int c_cnt; /* comment nesting level */
- int t_flg; /* transparency flag */
- #ifndef NARGS /*LP*/
- int fil_chr(FILE *, int *); /*LP*/
- void prt_hdr(void); /*LP*/
- void nl(void); /*LP*/
- #else /*LP*/
- int fil_chr(); /*LP*/
- void prt_hdr(); /*LP*/
- void nl(); /*LP*/
- #endif /*LP*/
-
- q_flg = FALSE;
- q1_flg = FALSE;
- cs_flg = FALSE;
- ce_flg = FALSE;
- t_flg = FALSE;
- c_cnt = 0;
-
- rch:
-
-
- /*
- * Fetch character from file
- */
-
- c = fil_chr(r_buffer, r_eoflg) & 0x7F;
- /* read only 7 bit ascii */ /*SRJ*/
-
- if (*r_eoflg) /* EOF encountered */
- return((char) c); /*LP*/
-
- switch(c) /* test the returned character */ /*SRJ*/
- {
- case '\n': /* carriage return */ /*SRJ*/
- nl(); /* output new line and line numbers */ /*SRJ*/
- ln_chr = 0; /* set to first char in line */ /*SRJ*/
- c = ' '; /* return a space */ /*SRJ*/
- break;
-
- case '\f': /* form feed */ /*SRJ*/
- prt_hdr(); /* output header and start new page*/ /*SRJ*/
- fprintf(l_buffer, " ");
- /* space over line #s */ /*SRJ*/
- ln_chr = 0; /* set to first char in line */ /*SRJ*/
- c = ' '; /* set char to blank */ /*SRJ*/
- break;
-
- case '\t': /* tab character */ /*SRJ*/
- do /* expand the tabs */ /*SRJ*/
- fputc(' ', l_buffer); /*SRJ*/
- while ( (++ln_chr % tab_cnt) != 0); /*SRJ*/
- c = ' '; /* set char to blank */ /*SRJ*/
- break;
-
-
- default:
- ln_chr++; /* move to next char pos */ /*SRJ*/
- if ( iscntrl(c) ) /* insure no control chars */ /*SRJ*/
- c = ' ';
- fputc(c, l_buffer); /* and output next char */ /*SRJ*/
- }
-
- if (rd_flg)
- return((char) c); /*LP*/
-
- if (t_flg)
- {
- t_flg = !t_flg;
- goto rch;
- }
-
- if (c == '\\')
- {
- t_flg = TRUE;
- goto rch;
- }
- /*
- If the character is not part of a quoted string
- check for and process commented strings...
- nested comments are handled correctly but unbalanced
- comments are not ... the assumption is made that
- the syntax of the program being xref'd is correct
- */
-
- if (!q_flg && !q1_flg)
- {
- if (c == '*' && c_cnt && !cs_flg)
- {
- ce_flg = TRUE;
- goto rch;
- }
- if (c == '/' && ce_flg)
- {
- c_cnt -= 1;
- ce_flg = FALSE;
- goto rch;
- }
- ce_flg = FALSE;
- if (c == '/')
- {
- cs_flg = TRUE;
- goto rch;
- }
- if (c == '*' && cs_flg)
- {
- c_cnt += 1;
- cs_flg = FALSE;
- goto rch;
- }
- cs_flg = FALSE;
-
- if (c_cnt) goto rch;
- } /* if (!q_flg && !q1_flg) */
-
- /*
- Check for and process quoted strings
- */
-
- if ( c == '"' && !q1_flg)
- {
- /* toggle quote flag */
- q_flg = !q_flg;
- if (debug)
- printf("q_flg toggled to: %d\n" , q_flg);
- goto rch;
- }
- if (q_flg) goto rch;
-
- if (c == '\'')
- {
- /* toggle quote flag */
- q1_flg = !q1_flg;
- if (debug)
- printf("q1_flg toggled to: %d\n" , q1_flg);
- goto rch;
- }
- if (q1_flg) goto rch;
-
- /*
- Valid character ... return to caller
- */
-
- return ((char) c); /*LP*/
- }
- /*rdchr.
- -----------------------------------------------*/
- int fil_chr(f_buffer,f_eof) /*LP*/
- FILE *f_buffer;
- int *f_eof;
-
- {
- int fc;
-
- fc = getc(f_buffer);
- if (fc == CPMEOF || fc == EOF)
- {
- *f_eof = TRUE;
- fc = NUL0;
- }
- return(fc);
- }
- /* CHECK THE TOKEN */ /*SRJ*/
-
-
- int chk_token(c_token) /*LP*/
- char *c_token;
-
- {
- char u_token[MAX_LEN];
- int i;
-
- {
- if (r_flg) return(TRUE);
- i = 0;
- do
- {
- u_token[i] = toupper(c_token[i]);
- }
- while (c_token[i++] != NUL0);
-
- switch(u_token[0])
- {
- case 'A':
- if (strcmp(u_token,"AUTO") == 0)
- return(FALSE);
- break;
- case 'B':
- if (strcmp(u_token,"BREAK") == 0)
- return(FALSE);
- break;
- case 'C':
- if (strcmp(u_token,"CHAR") == 0)
- return(FALSE);
- if (strcmp(u_token,"CONTINUE") == 0)
- return(FALSE);
- if (strcmp(u_token,"CASE") == 0)
- return(FALSE);
- break;
-
- case 'D':
- if (strcmp(u_token,"DOUBLE") == 0)
- return(FALSE);
- if (strcmp(u_token,"DO") == 0)
- return(FALSE);
- if (strcmp(u_token,"DEFAULT") == 0)
- return(FALSE);
- break;
- case 'E':
- if (strcmp(u_token,"EXTERN") == 0)
- return(FALSE);
- if (strcmp(u_token,"ELSE") == 0)
- return(FALSE);
- if (strcmp(u_token,"ENTRY") == 0)
- return(FALSE);
- break;
- case 'F':
- if (strcmp(u_token,"FLOAT") == 0)
- return(FALSE);
- if (strcmp(u_token,"FOR") == 0)
- return(FALSE);
- break;
- case 'G':
- if (strcmp(u_token,"GOTO") == 0)
- return(FALSE);
- break;
- case 'I':
- if (strcmp(u_token,"INT") == 0)
- return(FALSE);
- if (strcmp(u_token,"IF") == 0)
- return(FALSE);
- break;
- case 'L':
- if (strcmp(u_token,"LONG") == 0)
- return(FALSE);
- break;
- case 'R':
- if (strcmp(u_token,"RETURN") == 0)
- return(FALSE);
- if (strcmp(u_token,"REGISTER") == 0)
- return(FALSE);
- break;
- case 'S':
- if (strcmp(u_token,"STRUCT") == 0)
- return(FALSE);
- if (strcmp(u_token,"SHORT") == 0)
- return(FALSE);
- if (strcmp(u_token,"STATIC") == 0)
- return(FALSE);
- if (strcmp(u_token,"SIZEOF") == 0)
- return(FALSE);
- if (strcmp(u_token,"SWITCH") == 0)
- return(FALSE);
- break;
- case 'T':
- if (strcmp(u_token,"TYPEDEF") == 0)
- return(FALSE);
- break;
- case 'U':
- if (strcmp(u_token,"UNION") == 0)
- return(FALSE);
- if (strcmp(u_token,"UNSIGNED") == 0)
- return(FALSE);
- break;
- case 'W':
- if (strcmp(u_token,"WHILE") == 0)
- return(FALSE);
- break;
- }
- }
- return (TRUE);
- }
- /*chk_token.
- ---------------------------------------------*/
- /* STORE THE TOKEN */ /*SRJ*/
-
- /*
- * Install parsed token and line reference in linked structure
- */
-
- void put_token(p_token, p_ref)
- char *p_token;
- int p_ref;
-
- {
- int hsh_index;
- int i;
-
- /* unsigned long j; */ /*SRJ*/
- long int j; /*RSW*/
- int d;
- int found;
- struct id_blk *idptr;
- #if RFPTR_1 /* This variable is not used */ /*LP*/
- struct rf_blk *rfptr;
- #endif /*LP*/
-
- #ifndef NARGS /*LP*/
- struct id_blk *alloc_id(char *); /*LP*/
- struct rf_blk *alloc_rf(int); /*LP*/
- struct rf_blk *add_rf(struct rf_blk *, int); /*LP*/
- void chain_alpha(struct id_blk *, char *); /*LP*/
- #else /*LP*/
- struct id_blk *alloc_id();
- struct rf_blk *alloc_rf();
- struct rf_blk *add_rf();
- void chain_alpha(); /*LP*/
- #endif /*LP*/
-
- if (l_flg) return;
- j = 0;
- for (i = 0; p_token[i] != NUL0; i++) /* Hashing algorithm is far from */
- j = j * 10 + p_token[i]; /* memory-bound index vector! */
-
- hsh_index = j % MAX_WRD; /*SRJ*/
-
- if (debug)
- printf("hash index=%d ", hsh_index);
-
- found = FALSE;
- d = 1;
- do /* while (!found); */
- {
- idptr = id_vector[hsh_index];
- if (idptr == NUL0)
- {
- id_cnt++;
- idptr = id_vector[hsh_index] = alloc_id(p_token);
- chain_alpha(idptr, p_token);
- idptr->top_lnk = idptr->lst_lnk = alloc_rf(p_ref);
- found = TRUE;
- if (debug)
- printf("empty cell in vector\n");
- }
- else
- if (strcmp(p_token, idptr->id_name) == 0)
- {
- idptr->lst_lnk = add_rf(idptr->lst_lnk, p_ref);
- if (debug)
- printf("duplicate token\n");
- found = TRUE;
- }
- else
- {
- hsh_index += d;
- if (debug)
- printf("hash clash hash index=%d\n", hsh_index);
- d += 2;
- #if RHSH_CN1 /*LP*/
- rhsh_cnt++;
- #endif /*LP*/
- if (hsh_index >= MAX_WRD)
- hsh_index -= MAX_WRD;
- if (d == MAX_WRD)
- {
- printf("\nERROR: Symbol table overflow\n");
- exit(0);
- }
- } /* else for if (strcmp(p_token,idptr->id_name) == 0) */
- /* also else of if (idptr == NUL0) */
- }
- while (!found);
-
- return;
- }
- /*put_token.
- --------------------------------------------*/
- /* BUILD THE CHAINS */ /*SRJ*/
-
- void chain_alpha(ca_ptr,ca_token)
- struct id_blk *ca_ptr;
- char *ca_token;
-
- {
- char c;
- #if F_1 /* Variable not used */ /*LP*/
- int f;
- #endif /*LP*/
- struct id_blk *cur_ptr;
- struct id_blk *lst_ptr;
- /*** int isupper(); ****/ /** Lattice C macro **/
-
-
- c = ca_token[0];
- if (c == '_') c = 0;
- else
- /** isupper(c) ? c=1+((c-'A')*2) : c=2+((c-'a')*2) ; error or not??
- ** A good one for the puzzle book! Is the () required around (c=..)?
- ** C86 and Lattice C both req the ()'s, BDS C did not.
- ** Is it required because = has lower precedence than ?: ????
- **/
- isupper(c) ? (c=1+((c-'A')*2)) : (c=2+((c-'a')*2)) ;
-
- if (alpha_vector[c].alpha_top == NUL0)
- {
- alpha_vector[c].alpha_top =
- alpha_vector[c].alpha_lst = ca_ptr;
- ca_ptr->alpha_lnk = NUL0;
- return;
- }
-
- /* check to see if new id_blk should be inserted between
- * the alpha_vector header block and the first id_blk in
- * the current alpha chain
- */
-
- if (strcmp(alpha_vector[c].alpha_top->id_name, ca_token) >0)
- {
- ca_ptr->alpha_lnk=alpha_vector[c].alpha_top;
- alpha_vector[c].alpha_top=ca_ptr;
- return;
- }
-
- if (strcmp(alpha_vector[c].alpha_lst->id_name, ca_token) < 0)
- {
- alpha_vector[c].alpha_lst->alpha_lnk = ca_ptr;
- ca_ptr->alpha_lnk = NUL0;
- alpha_vector[c].alpha_lst=ca_ptr;
- return;
- }
-
- cur_ptr = alpha_vector[c].alpha_top;
- while (strcmp(cur_ptr->id_name, ca_token) < 0)
- {
- lst_ptr = cur_ptr;
- cur_ptr = lst_ptr->alpha_lnk;
- }
-
- lst_ptr->alpha_lnk = ca_ptr;
- ca_ptr->alpha_lnk = cur_ptr;
- return;
- }
- /*chain_alpha.
- -----------------------------------------*/
- /* GET MEMORY FOR TOKEN TREE */ /*SRJ*/
- struct id_blk
- *alloc_id(aid_token)
- char *aid_token;
-
- {
- int ai;
- struct id_blk *aid_ptr;
-
- if ((aid_ptr = ID_ALLOC) == NULL_PTR) /*LP*/
- {
- printf("\nERROR: Unable to allocate identifier block\n");
- exit(0);
- }
- ai=0;
- do
- {
- aid_ptr->id_name[ai] = aid_token[ai];
- }
- while (aid_token[ai++] != NUL0);
- return (aid_ptr);
- }
- /*id_blk.
- -----------------------------------------*/
-
- struct rf_blk
- *alloc_rf(arf_ref)
- int arf_ref;
-
- {
- int ri;
- struct rf_blk *arf_ptr;
-
- if ((arf_ptr = RF_ALLOC) == NULL_PTR) /*LP*/
- {
- printf("\nERROR: Unable to allocate reference block\n");
- exit(0);
- }
- arf_ptr->ref_item[0] = arf_ref;
- arf_ptr->NEXT_REF = NUL0; /* Overwrite this setting for CIC86 */ /*LP*/
- arf_ptr->ref_cnt = 1;
- for (ri=1; ri < MAX_REF; ri++)
- arf_ptr->ref_item[ri] = NUL0;
- return (arf_ptr);
- }
- /*alloc_rf.
- ------------------------------------------*/
- /* STORE REFERENCE IN TREE */ /*SRJ*/
-
- struct rf_blk
- *add_rf(adr_ptr,adr_ref)
-
- struct rf_blk *adr_ptr;
- int adr_ref;
-
- {
- struct rf_blk *tmp_ptr;
-
- tmp_ptr = adr_ptr;
- if (adr_ptr->ref_cnt == MAX_REF)
- {
- tmp_ptr = adr_ptr->NEXT_REF = alloc_rf(adr_ref); /*LP*/
- }
- else
- {
- adr_ptr->ref_item[adr_ptr->ref_cnt++] = adr_ref;
- }
- return (tmp_ptr);
- }
- /*rf_blk.
- ------------------------------------------*/
- /* PRINT THE CROSS REFERENCE TABLE */ /*SRJ*/
-
- void prnt_tbl()
- {
- int prf_cnt;
- int pti;
- int pref;
- int lin_cnt;
- struct id_blk *pid_ptr;
- struct rf_blk *ptb_ptr;
- #ifndef NARGS /*LP*/
- void prt_hdr(void); /*LP*/
- void nl(void); /*LP*/
- #else /*LP*/
- void prt_hdr(); /*LP*/
- void nl(); /*LP*/
- #endif /*LP*/
-
- prt_ref = TRUE;
- prt_hdr();
- if (o_flg) /*LP*/
- printf("\nWriting cross-references\n"); /*LP*/
- nl();
- for (pti=0;pti<MX_ALPHA;pti++)
- {
- if ((pid_ptr = alpha_vector[pti].alpha_top) != NUL0)
- {
- do /* while ((pid_ptr=pid_ptr->alpha_lnk) != NUL0) */
- {
- fprintf(l_buffer,"%-14.13s: ", pid_ptr->id_name); /*WHR*/
- ptb_ptr = pid_ptr->top_lnk;
- lin_cnt = prf_cnt = 0;
- do /* while (pref) */
- {
- /* Get another reference block if necessary */ /*LP*/
- if (prf_cnt == MAX_REF)
- {
- prf_cnt=0;
- ptb_ptr = ptb_ptr->NEXT_REF; /*LP*/
- }
- if (IS_PTR(ptb_ptr)) /* ptb_ptr points to a rf_blk */ /*LP*/
- {
- if ((pref=ptb_ptr->ref_item[prf_cnt++]) != 0)
- {
- if (++lin_cnt > REFS_LIN )
- {
- nl();
- fprintf(l_buffer,"%16s", ": ");
- lin_cnt = 1;
- }
- fprintf(l_buffer,"%-4d ",pref); /*WHR*/
- } /* if ((pref=ptb_ptr->ref_item[prf_cnt++]) != 0) */
- } /* if (IS_PTR(ptb_ptr)) */
- else
- pref=0;
- }
- while (pref);
- nl();
- nl(); /*LP*/
- }
- while ((pid_ptr = pid_ptr->alpha_lnk) != NUL0);
- } /* if ((pid_ptr = alpha_vector[pti].alpha_top) != NUL0) */
- } /* for (pti=0;pti<MX_ALPHA;pti++) */
- }
- /*prnt_tbl.
- ---------------------------------------*/
- /* TOP OF PAGE AND PRINT THE HEADER */ /*SRJ*/
-
- void prt_hdr()
-
- {
- fprintf(l_buffer,
- "\r\f%-10s [file d/t= %d/%02d/%02d %d:%02d] [clock d/t= %d %s %d %d:%02d:%02d] Page %d\n\n",
- gbl_fil, file_mo, file_d, file_y, file_h, file_mi,
- d, months[mo], y, h, mi, s, ++pagno); /*SRJ*/
-
- paglin =3;
- return;
- }
- /* NEW LINE */ /*SRJ*/
-
- void nl()
-
- {
- int digit; /*LP*/
-
- fputc('\n',l_buffer); /* output cr/lf */ /*SRJ*/
-
- if (++paglin >= LINE_PAG )
- prt_hdr();
- if (!prt_ref)
- {
- fprintf(l_buffer,"%4d ", ++linum); /*SRJ*/
- if (i_flg) /*SRJ*/
- fprintf(l_buffer," %4d: ",++edtnum); /*SRJ*//*WHR*/
- }
-
- /* print the status on the console */
- if (o_flg)
- if (prt_ref) /*LP*/
- putchar('.'); /*LP*/
- else /* Listing program */ /*LP*/
- {
- if (linum % 60 == 1)
- printf("\n<%d>\t", linum);
- else
- { /*LP*/
- putchar((digit = (linum % 10)) + '0'); /*LP*/
- if (!digit) /*LP*/
- putchar(' '); /*LP*/
- } /*LP*/
- }
- return;
- }
- /*nl.
- -------------------------------------------*/
- /* COMPILER DEPENDENT FUNCTIONS TO GET SYSTEM TIME AND DATE*/ /*LP*/
-
- #if CIC86 /*LP*/
- /* Computer Innovations C-86 start */ /*LP*/
- void getclk_1()
-
- {
- void getclk_2();
-
- segread(®x); /* get the segment registers */ /*SRJ*/
- reg.ds = regx.dsx; /* save the ds in the sysint data */ /*SRJ*/
- reg.es = regx.esx; /* save the es in the sysint data */ /*SRJ*/
- getclk_2();
- } /* getclk_1.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- #if CIC86 || LATTICE2 /*LP*/
-
- /* Computer Innovations C-86 and Lattice, Version 2 */ /*LP*/
- void getclk_2()
-
- {
- /* THE FOLLOWING CODE GETS THE DATE AND THE TIME FROM DOS. IT USES THE
- ROUTINES SYSINT AND SEGREAD PROVIDED BY THE CI C-86 LIBRARY. THIS IS CI C-86
- DEPENDENT CODE AND MUST BE CHANGED FOR OTHER COMPILERS */ /*SRJ*/
- /* added Lattice C ver 2.00 int86 calls to do the same */ /*RSW*/
-
- /* get the date */ /*SRJ*/
- REG.ax = 0x2A00; /* date request code */ /*SRJ*/
- INT21; /* DOS interrupt */ /*SRJ*/
- y = REG.cx; /* store year */ /*SRJ*/
- mo = REG.dx >> 8; /* store month */ /*SRJ*/
- d = REG.dx & 0xFF; /* get the day */ /*SRJ*/
-
- /* get the time */ /*SRJ*/
- REG.ax = 0x2C00; /* time request code */ /*SRJ*/
- INT21; /* DOS interrupt */ /*SRJ*/
- h = REG.cx >> 8; /* get hours */ /*SRJ*/
- mi = REG.cx & 0xFF; /* get minutes */ /*SRJ*/
- s = REG.dx >> 8; /* get seconds */ /*SRJ*/
- } /* getclk_2.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- #if LATTICE3 /*LP*/
-
- /* Lattice, Version 3 */ /*LP*/
- void getclk_3() /*LP*/
-
- /* THE FOLLOWING CODE USES THE NEW LATTICE C VERSION 3.0 FUNCTION GETCLK
- TO GET THE DATE AND TIME. */ /*LP*/
-
- {
- unsigned char clock[8]; /* Array for getclk */ /* LP */
-
- getclk(clock); /*LP*/
- y = clock[1] + 1980; /* store year */ /*LP*/
- mo = clock[2]; /* store month */ /*LP*/
- d = clock[3]; /* get the day */ /*LP*/
- h = clock[4]; /* get hours */ /*LP*/
- mi = clock[5]; /* get minutes */ /*LP*/
- s = clock[6]; /* get seconds */ /*LP*/
- } /*getclk_3.
-
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- /* COMPILER DEPENDENT CODE TO GET A FILE'S TIME AND DATA */ /*LP*/
- #if CIC86 /*LP*/
-
- /* Computer Innovations C-86 */ /*LP*/
- void getft_1() /*LP*/
-
- { /*LP*/
- void dosft(); /*LP*/
- if (fclose(tb)) /* close the file */ /*SRJ*/ /*LP*/
- { /*LP*/
- printf(\n"ERROR: Unable to close input file: %s\n", gbl_fil); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
-
- /* note-we have no way to get an error indication back from the dos call
- below (file open), so we have to open it to see if it is there before
- we can use the proceedure below */ /*SRJ*/
-
- /* now get the file date and time */ /*SRJ*/
-
- /* open the file - we assume the file exists */ /*SRJ*/
- REG.ax = 0x3D00; /* open request code */ /*SRJ*/ /*LP*/
- REG.dx = gbl_fil; /* address of file name */ /*SRJ*/ /*LP*/
- INT21; /* DOS interrupt */ /*SRJ*/ /*LP*/
- handle = REG.ax; /* store file handle */ /*SRJ*/ /*LP*/
-
- dosft(); /* Get file date and time */ /*LP*/
-
- /* close the file */ /*SRJ*/
- REG.bx = handle; /*SRJ*/ /*LP*/
- REG.ax = 0x3D00; /*SRJ*/ /*LP*/
- INT21; /* DOS interrupt */ /*SRJ*/ /*LP*/
-
- } /* getft_1.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- #if LATTICE2 /*LP*/
-
- /* Lattice C, Version 2.0 */ /*LP*/
- void getft_2() /*LP*/
-
- { /*LP*/
- int fileno(); /*LP*/
- void dosft(); /*LP*/
-
- handle = fileno(tb); /*LP*/
- dosft(); /* Get file date and time */ /*LP*/
- if (fclose(tb)) /* close the file */ /*LP*/
- { /*LP*/
- printf("\nERROR: Unable to close input file: %s\n", gbl_fil); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
-
- } /* getft_2.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- #if CIC86 || LATTICE2 /*LP*/
-
- /* Use DOS calls to get file date and time */ /*LP*/
-
- void dosft() /*LP*/
-
- { /*LP*/
-
- /* get the date and time */ /*SRJ*/
- REG.ax = 0x5700; /* time request code */ /*SRJ*/ /*LP*/
- REG.bx = handle; /* file handle in bx */ /*SRJ*/ /*LP*/
- INT21; /* DOS interrupt */ /*SRJ*/ /*LP*/
-
- /* unpack the file time */ /*SRJ*/
- file_h=(REG.cx >> 11) & 0x1F; /* get hours */ /*SRJ*/ /*LP*/
- file_mi=(REG.cx >> 5) & 0x3f; /* get minutes */ /*SRJ*/ /*LP*/
-
- /* unpack the file date */ /*SRJ*/
- file_d=REG.dx & 0x1F; /* get the day */ /*SRJ*/ /*LP*/
- file_mo= (REG.dx >> 5) & 0x0F; /* get the month */ /*SRJ*/ /*LP*/
- file_y=( (REG.dx >> 9) & 0x7F )+80; /* get the month */ /*SRJ*/ /*LP*/
-
- } /* dosft.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- #if LATTICE3 /*LP*/
-
- /* Lattice C, Version 3.0 */ /*LP*/
- void getft_3() /*LP*/
-
- { /*LP*/
- union FILETIME /*LP*/
- { /*LP*/
- long ft_in; /*LP*/
- struct DATETIME /*LP*/
- { /*LP*/
- struct TIME /*LP*/
- { /*LP*/
- unsigned hour:5; /*LP*/
- unsigned minute:6; /*LP*/
- unsigned second:5; /*LP*/
- } t; /*LP*/
- struct DATE /*LP*/
- { /*LP*/
- unsigned year:7; /*LP*/
- unsigned month:4; /*LP*/
- unsigned day:5; /*LP*/
- } d; /*LP*/
- } dt; /*LP*/
- } ft; /*LP*/
-
- ft.ft_in = getft((int) fileno(tb)); /*LP*/
- /* See Lattice C Ver. 3.0 manual */ /*LP*/
- file_h = ft.dt.t.hour; /* get hours */ /*LP*/
- file_mi = ft.dt.t.minute; /* get minutes */ /*LP*/
- file_d = ft.dt.d.day; /* get the day */ /*LP*/
- file_mo = ft.dt.d.month; /* get the month */ /*LP*/
- file_y = ft.dt.d.year + 80; /* get the year*/ /*LP*/
- if (fclose(tb)) /* close the file */ /*LP*/
- { /*LP*/
- printf("\nERROR: Unable to close input file: %s\n", gbl_fil); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
-
- } /* getft_3.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- /* COMPILER DEPENDENT CODE WHICH RETURNS TRUE IF lbuffer IS A FILE */ /*LP*/
-
- /* Dummy which always return a value of TRUE */ /*LP*/
- int l_isf0() /*LP*/
-
- { /*LP*/
- return(TRUE); /*LP*/
- } /* l_isf0.
- -------------------------------------------*/ /*LP*/
- #if LATTICE2 /*LP*/
-
- int l_isf2() /*LP*/
-
- { /*LP*/
- REG.ax = 0x4400; /* DOS I/O Control for Devices */ /*LP*/
- REG.bx = fileno(l_buffer) /*LP*/
- if (INT21 & 1) /* Carry flag from DOS interrupt */ /*LP*/
- { /*LP*/
- printf("\nERROR: Unable to get file characteristics for "); /*LP*/
- printf("output file\n"); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
- return(!(REG.dx & 0x80)); /* Bit 7 is set if not a disk file */ /*LP*/
- } /* l_isf2().
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- #if LATTICE3 /*LP*/
-
- int l_isf3() /*LP*/
-
- { /*LP*/
- int cw; /*LP*/
-
- if (getfc((int) fileno(l_buffer), &cw)) /*LP*/
- { /*LP*/
- printf("\nERROR: Unable to get file characteristics for "); /*LP*/
- printf("output file\n"); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
- return(!(cw & 0x80)); /* Bit 7 is set if not a disk file */ /*LP*/
- } /* l_isf3().
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- /* Flush l_buffer if necessary */ /*LP*/
-
- /* Dummy which does nothing */ /*LP*/
- void l_fl0() /*LP*/
-
- { /*LP*/
- return; /*LP*/
- } /* l_fl0
- -------------------------------------------*/ /*LP*/
- #if CIC86 /*LP*/
-
- l_fl1 /*LP*/
-
- { /*LP*/
- if (fflush(l_buffer)) /*LP*/
- { /*LP*/
- printf /*LP*/
- ("\nERROR: Unable to flush output file: %s\n", lst_fil); /*LP*/
- exit(0); /*LP*/
- } /*LP*/
- } /* l_fl1.
- -------------------------------------------*/ /*LP*/
- #endif
- /* COMPILER DEPENDENT ERROR MESSAGE FOR -i FLAG */ /*LP*/
-
- #if LATTICE3 /*LP*/
-
- void i_mes2() /*LP*/
-
- { /*LP*/
- printf("Enable file inclusion with "); /*LP*/
- printf("extended search\n"); /*LP*/
- printf(" in directories specified "); /*LP*/
- printf("in the environment\n"); /*LP*/
- printf(" variable named for the "); /*LP*/
- printf("include file's file\n"); /*LP*/
- printf(" name extension and then "); /*LP*/
- printf("in the environment\n"); /*LP*/
- printf(" variable named INCLUDE\n"); /*LP*/
- printf(" -in = Enable file inclusion with no "); /*LP*/
- printf("extended search\n"); /*LP*/
- } /* i_mes2.
- -------------------------------------------*/ /*LP*/
- #else /*LP*/
- void i_mes1() /*LP*/
-
- { /*LP*/
- printf("Enable file inclusion\n"); /*LP*/
- } /* i_mes1.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- /* COMPILER DEPENDENT FILE OPEN FOR INPUT FILES */ /*LP*/
-
- #if LATTICE3 /*LP*/
-
- FILE *opn_i2(filnam) /*LP*/
-
- char *filnam; /*LP*/
- /*LP*/
- { /*LP*/
- FILE *buffer; /*LP*/
-
- if (in_flg) /* No extended directory search. */ /*LP*/
- buffer = fopen(filnam, "r"); /*** input file ***/ /*WHR*/
- else /* Extended directory search. Note that since */ /*LP*/
- /* the program earlier got the date and time */ /*LP*/
- /* the main program from a standard fopen, */ /*LP*/
- /* the extension does no harm for it. */ /*LP*/
- buffer = fopene(filnam, "r", "INCLUDE"); /*LP*/
- return(buffer); /*LP*/
- } /* opn_i2.
- -------------------------------------------*/ /*LP*/
- #else /*LP*/
- FILE *opn_i1(filnam) /*LP*/
-
- char *filnam; /*LP*/
-
- { /*LP*/
- FILE *buffer; /*LP*/
-
- buffer = fopen(filnam, "r"); /*** input file ***/ /*WHR*/
- return(buffer); /*LP*/
- } /* opn_i1.
- -------------------------------------------*/ /*LP*/
- #endif /*LP*/
- /*============= end of file xc.c ==========================*/